package com.gds.wiki.cloud.memberCenter.client.member.hystrix;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gds.wiki.cloud.framework.common.dto.ResponseDto;
import com.gds.wiki.cloud.framework.common.exception.BizExceptionEnum;
import com.gds.wiki.cloud.framework.common.utils.ResponseDtoFactory;
import com.gds.wiki.cloud.memberCenter.client.member.api.MemberApi;
import com.gds.wiki.cloud.memberCenter.client.member.model.Member;
import com.gds.wiki.cloud.memberCenter.client.member.model.query.MemberQuery;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;


@Component
public class MemberApiFallbackFactory implements FallbackFactory<MemberApi> {

    public MemberApi create(Throwable throwable) {
        return new MemberApi() {

            @Override
            public ResponseDto<Member> getMember(MemberQuery memberQuery) {
                return ResponseDtoFactory.GetInstance().build(BizExceptionEnum.API_EEROR);
            }

            @Override
            public ResponseDto<Page> getPage(MemberQuery memberQuery) {
                return ResponseDtoFactory.GetInstance().build(BizExceptionEnum.API_EEROR);
            }
        };
    }
}

